<?php

if (!defined('_PAGE_'))
    include _FLEP_LIB_DIR_.'/page.inc';

$css = array( 'jquery-ui.css', 'main.css', 'add_estudiante.css');
$javascript = array('jquery-1.9.1.js', 'jquery-ui.js', "common.js", 'add_common.js', 'add_docente.js', 'search.js');

flep_structure($structure, 'docente');
$structure['data'][0]['id'] = false;
if(isset($_GET['id'])){
    $structure['data'][0]['id'] = $_GET['id'];
}

function include_page($structure){
if($edit = $structure['data'][0]['id']){
    $structure['where'][0] = sprintf("`docentes`.`id`='%s'", flep_decode($structure['data'][0]['id']));
    flep_search_all($structure);
}
?>
<h3><a href="main.php?page=docente">Docentes</a></h3>
    <br>
    <div class="menu">
        <a href="?page=add_docente">Agregar</a>&nbsp;|&nbsp;
        <a href="?page=curso">Cursos</a>&nbsp;|&nbsp;
        <?php flep_page_search($structure); ?>
    </div>
    <br><br>
    <p class="error" id="perror"></p>
    <form action="store.php?type=docente" method="POST" id="form_docente" onsubmit="return flepues_validar_estudiante();">
    <input type="hidden" value="<?php echo ($edit?flep_encode($structure['data'][0]['id']):'')?>" id="id" name="id">
        <table>
           <tr>
           <tr>
                <td><label>Nombre:</label></td>
                <td><input type="text" autofocus name="nombre" style="width: 250px" value="<?php echo ($edit?$structure['data'][0]['nombre']:'')?>" required placeholder="Nombre Completo"></td>
            </tr>
            <tr id="tr_code">
                <td><label>Nombre de Usuario</label></td>
                <td><input type="text" name="usuario" style="width: 100px" autocomplete="off" value="<?php echo ($edit?$structure['data'][0]['usuario']:'')?>" required placeholder="Usuario"></td>
            </tr>
            <tr>
                <td><label>Contrase&ntilde;a:</label></td>
                <td><input type="password" name="clave" style="width: 200px" autocomplete="off" placeholder="Min. 6 caracteres"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="password" name="clave2" style="width: 200px" autocomplete="off" placeholder="Verificar Contrase&ntilde;a"></td>
            </tr>
            <tr>
                <td><label>Fecha de Ingreso:</label></td>
                <td><input type="text" name="fecha_ingreso" id="fecha_ingreso" style="width: 200px" value="<?php echo ($edit?$structure['data'][0]['fecha_ingreso']:'')?>" required placeholder="Formato: YYYY-MM-DD" ></td>
            </tr>
            <tr>
                <td><label>Telefono:</label></td>
                <td><input type="text" name="telefono" style="width: 200px" value="<?php echo ($edit?$structure['data'][0]['telefono']:'')?>" pattern="[0-9]{8}" placeholder="Formato: 12345678"></td>
            </tr>
             <tr>
                <td><label>Correo Electronico:</label></td>
                <td><input type="email" name="correo" style="width: 250px" value="<?php echo ($edit?$structure['data'][0]['correo']:'')?>" placeholder="Formato: correo@servidor" ></td>
            </tr>
            <tr>
                <td><label>Activo:</label></td>
                <td><input type="checkbox" name="activo" value="1" <?php echo ($edit && $structure['data'][0]['activo'] === '1'? 'checked' :'')?>></td>
            </tr>
            <tr>
                <td><label onclick="flep_show_comment('textarea_estudiante');" title="Click para mostrar/ocultar">Comentarios:</label></td>
                <td><textarea style="display: none;" form="form_docente" name="comentario" id="textarea_estudiante"></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Guardar" style="margin-right: 100px;"><input type="reset" value="Limpiar"></td>
            </tr>
        </table>
    </form>
<?php
}

function include_menu(){
    include_main_menu();
}

?>
